import request from '@/utils/request';

// 获取角色列表
export async function getRoleList(params?: any) {
  return request.get('/api/roles', { params });
}

// 获取角色详情
export async function getRoleDetail(id: string) {
  return request.get(`/api/roles/${id}`);
}

// 创建角色
export async function createRole(data: any) {
  return request.post('/api/roles', data);
}

// 更新角色
export async function updateRole(data: any) {
  return request.put(`/api/roles/${data.id}`, data);
}

// 删除角色
export async function deleteRole(id: string) {
  return request.delete(`/api/roles/${id}`);
}

// 批量删除角色
export async function batchDeleteRoles(ids: string[]) {
  return request.post('/api/roles/batch-delete', { ids });
}

// 获取角色权限
export async function getRolePermissions(id: string) {
  return request.get(`/api/roles/${id}/permissions`);
}

// 设置角色权限
export async function setRolePermissions(id: string, permissionIds: string[]) {
  return request.post(`/api/roles/${id}/permissions`, { permissionIds });
}
